/** @file  is_int.c
 *  @brief To check the integer
 * 
 *  Function to check the  integer range 
 *   
 *  @author Karthik M 
 *  @bug No  bugs.
 */


#include "header.h"

int is_int (char *s)
{						
   long long num = 0 ;								//! store more than integer range 
   int sign = 0 ;									//!  store the sign 

   sign = ( *s == '-') ? -1:1 ;				
   if (*s == '+' || *s == '-' )
      s++ ;

   for (num = 0; (*s >= '0') && (*s <= '9') ;s++)
   {     //! convert to int
      num = num*10 + (*s -'0');
   }
#if DEBUG
   printf (" sigh = %d \n",sign);
   printf (" lonfag =%lld \n",num);
#endif
   num *= sign;
   if ( num <= INT_MAX && num >=INT_MIN )
   {				/* check the integer range */

      return 1;
   }

   return 0;											/* return faliure if not integer */

}



